package com.acyouzi.leetcode.string;

import java.util.HashMap;

/**
 * 17/9/11 15:17
 *
 * @author sunxu
 */
public class LongestPalindrome {
  public int longestPalindrome(String s) {
    HashMap<Character, Integer> map = new HashMap<>();
    for (char i : s.toCharArray()){
      map.put(i,map.getOrDefault(i,0)+1);
    }
    int odd = 0;
    int sum = 0;
    for (int i : map.values()){
      if (i % 2 == 0){
        sum += i;
      }else{
        sum += (i - 1);
        odd = 1;
      }
    }
    return odd + sum;
  }
}
